package com.charlie.beans;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Вова
 */
@Entity
@Table(name = "SO_HISTORY")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "SoHistory.findAll", query = "SELECT s FROM SoHistory s"),
    @NamedQuery(name = "SoHistory.findBySoHistoryId", query = "SELECT s FROM SoHistory s WHERE s.soHistoryId = :soHistoryId"),
    @NamedQuery(name = "SoHistory.findByChangeDate", query = "SELECT s FROM SoHistory s WHERE s.changeDate = :changeDate"),
    @NamedQuery(name = "SoHistory.findByCommentary", query = "SELECT s FROM SoHistory s WHERE s.commentary = :commentary")})
public class SoHistory implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @SequenceGenerator(name = "SO_HISTORY_SEQ", sequenceName = "SO_HISTORY_SO_HISTORY_ID_SEQ", allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SO_HISTORY_SEQ")    
    @Column(name = "SO_HISTORY_ID")
    private Integer soHistoryId;
    @Basic(optional = false)
    @NotNull
    @Column(name = "CHANGE_DATE")
    @Temporal(TemporalType.DATE)
    private Date changeDate;
    @Size(max = 250)
    @Column(name = "COMMENTARY")
    private String commentary;
    @JoinColumn(name = "USER_ID", referencedColumnName = "USERS_ID")
    @ManyToOne
    private Users userId;
    @JoinColumn(name = "STATUS_DICT_ID", referencedColumnName = "STATUS_DICT_ID")
    @ManyToOne(optional = false)
    private StatusDict statusDictId;
    @JoinColumn(name = "SO_ID", referencedColumnName = "SO_ID")
    @ManyToOne(optional = false)
    private ShipmentOrder soId;

    public SoHistory() {
    }

    public SoHistory(Integer soHistoryId) {
        this.soHistoryId = soHistoryId;
    }

    public SoHistory(Integer soHistoryId, Date changeDate) {
        this.soHistoryId = soHistoryId;
        this.changeDate = changeDate;
    }

    public Integer getSoHistoryId() {
        return soHistoryId;
    }

    public void setSoHistoryId(Integer soHistoryId) {
        this.soHistoryId = soHistoryId;
    }

    public Date getChangeDate() {
        return changeDate;
    }

    public void setChangeDate(Date changeDate) {
        this.changeDate = changeDate;
    }

    public String getCommentary() {
        return commentary;
    }

    public void setCommentary(String commentary) {
        this.commentary = commentary;
    }

    public Users getUserId() {
        return userId;
    }

    public void setUserId(Users userId) {
        this.userId = userId;
    }

    public StatusDict getStatusDictId() {
        return statusDictId;
    }

    public void setStatusDictId(StatusDict statusDictId) {
        this.statusDictId = statusDictId;
    }

    public ShipmentOrder getSoId() {
        return soId;
    }

    public void setSoId(ShipmentOrder soId) {
        this.soId = soId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (soHistoryId != null ? soHistoryId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SoHistory)) {
            return false;
        }
        SoHistory other = (SoHistory) object;
        if ((this.soHistoryId == null && other.soHistoryId != null) || (this.soHistoryId != null && !this.soHistoryId.equals(other.soHistoryId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.charlie.beans.SoHistory[ soHistoryId=" + soHistoryId + " ]";
    }
    
}
